/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.dengues.model.warehouse.impl;

import java.util.Collection;

import org.dengues.model.warehouse.BlockExitType;
import org.dengues.model.warehouse.BlockType;
import org.dengues.model.warehouse.ConnectionType;
import org.dengues.model.warehouse.NodeType;
import org.dengues.model.warehouse.NoteType;
import org.dengues.model.warehouse.ProcessType;
import org.dengues.model.warehouse.WarehousePackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Process Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#getNode <em>Node</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#getNote <em>Note</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#getBlock <em>Block</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#getConnection <em>Connection</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#isIsblock <em>Isblock</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.ProcessTypeImpl#getExits <em>Exits</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProcessTypeImpl extends StorageImpl implements ProcessType {
    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static final String copyright = "// ============================================================================\r\n//\r\n// Copyright (C) 2006-2007 Dengues\r\n//\r\n// Google Group: http://groups.google.com/group/dengues\r\n// QQ Group: 24885404\r\n//\r\n// This library is free software; you can redistribute it and/or\r\n// modify it under the terms of the GNU Lesser General Public\r\n// License as published by the Free Software Foundation; either\r\n// version 2.1 of the License.\r\n//\r\n// This library is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r\n// Lesser General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with this program; if not, write to the Free Software\r\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r\n//\r\n// ============================================================================\r\n";

    /**
     * The cached value of the '{@link #getNode() <em>Node</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getNode()
     * @generated
     * @ordered
     */
    protected EList<NodeType> node;

    /**
     * The cached value of the '{@link #getNote() <em>Note</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getNote()
     * @generated
     * @ordered
     */
    protected EList<NoteType> note;

    /**
     * The cached value of the '{@link #getBlock() <em>Block</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getBlock()
     * @generated
     * @ordered
     */
    protected EList<BlockType> block;

    /**
     * The cached value of the '{@link #getConnection() <em>Connection</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getConnection()
     * @generated
     * @ordered
     */
    protected EList<ConnectionType> connection;

    /**
     * The default value of the '{@link #isIsblock() <em>Isblock</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #isIsblock()
     * @generated
     * @ordered
     */
    protected static final boolean ISBLOCK_EDEFAULT = false;

    /**
     * The cached value of the '{@link #isIsblock() <em>Isblock</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #isIsblock()
     * @generated
     * @ordered
     */
    protected boolean isblock = ISBLOCK_EDEFAULT;

    /**
     * The cached value of the '{@link #getExits() <em>Exits</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getExits()
     * @generated
     * @ordered
     */
    protected EList<BlockExitType> exits;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected ProcessTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return WarehousePackage.Literals.PROCESS_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<NodeType> getNode() {
        if (node == null) {
            node = new EObjectContainmentEList<NodeType>(NodeType.class, this, WarehousePackage.PROCESS_TYPE__NODE);
        }
        return node;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<NoteType> getNote() {
        if (note == null) {
            note = new EObjectContainmentEList<NoteType>(NoteType.class, this, WarehousePackage.PROCESS_TYPE__NOTE);
        }
        return note;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<BlockType> getBlock() {
        if (block == null) {
            block = new EObjectContainmentEList<BlockType>(BlockType.class, this, WarehousePackage.PROCESS_TYPE__BLOCK);
        }
        return block;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<ConnectionType> getConnection() {
        if (connection == null) {
            connection = new EObjectContainmentEList<ConnectionType>(ConnectionType.class, this, WarehousePackage.PROCESS_TYPE__CONNECTION);
        }
        return connection;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean isIsblock() {
        return isblock;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setIsblock(boolean newIsblock) {
        boolean oldIsblock = isblock;
        isblock = newIsblock;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, WarehousePackage.PROCESS_TYPE__ISBLOCK, oldIsblock, isblock));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<BlockExitType> getExits() {
        if (exits == null) {
            exits = new EObjectContainmentEList<BlockExitType>(BlockExitType.class, this, WarehousePackage.PROCESS_TYPE__EXITS);
        }
        return exits;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case WarehousePackage.PROCESS_TYPE__NODE:
                return ((InternalEList<?>)getNode()).basicRemove(otherEnd, msgs);
            case WarehousePackage.PROCESS_TYPE__NOTE:
                return ((InternalEList<?>)getNote()).basicRemove(otherEnd, msgs);
            case WarehousePackage.PROCESS_TYPE__BLOCK:
                return ((InternalEList<?>)getBlock()).basicRemove(otherEnd, msgs);
            case WarehousePackage.PROCESS_TYPE__CONNECTION:
                return ((InternalEList<?>)getConnection()).basicRemove(otherEnd, msgs);
            case WarehousePackage.PROCESS_TYPE__EXITS:
                return ((InternalEList<?>)getExits()).basicRemove(otherEnd, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case WarehousePackage.PROCESS_TYPE__NODE:
                return getNode();
            case WarehousePackage.PROCESS_TYPE__NOTE:
                return getNote();
            case WarehousePackage.PROCESS_TYPE__BLOCK:
                return getBlock();
            case WarehousePackage.PROCESS_TYPE__CONNECTION:
                return getConnection();
            case WarehousePackage.PROCESS_TYPE__ISBLOCK:
                return isIsblock() ? Boolean.TRUE : Boolean.FALSE;
            case WarehousePackage.PROCESS_TYPE__EXITS:
                return getExits();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @SuppressWarnings("unchecked")
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case WarehousePackage.PROCESS_TYPE__NODE:
                getNode().clear();
                getNode().addAll((Collection<? extends NodeType>)newValue);
                return;
            case WarehousePackage.PROCESS_TYPE__NOTE:
                getNote().clear();
                getNote().addAll((Collection<? extends NoteType>)newValue);
                return;
            case WarehousePackage.PROCESS_TYPE__BLOCK:
                getBlock().clear();
                getBlock().addAll((Collection<? extends BlockType>)newValue);
                return;
            case WarehousePackage.PROCESS_TYPE__CONNECTION:
                getConnection().clear();
                getConnection().addAll((Collection<? extends ConnectionType>)newValue);
                return;
            case WarehousePackage.PROCESS_TYPE__ISBLOCK:
                setIsblock(((Boolean)newValue).booleanValue());
                return;
            case WarehousePackage.PROCESS_TYPE__EXITS:
                getExits().clear();
                getExits().addAll((Collection<? extends BlockExitType>)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case WarehousePackage.PROCESS_TYPE__NODE:
                getNode().clear();
                return;
            case WarehousePackage.PROCESS_TYPE__NOTE:
                getNote().clear();
                return;
            case WarehousePackage.PROCESS_TYPE__BLOCK:
                getBlock().clear();
                return;
            case WarehousePackage.PROCESS_TYPE__CONNECTION:
                getConnection().clear();
                return;
            case WarehousePackage.PROCESS_TYPE__ISBLOCK:
                setIsblock(ISBLOCK_EDEFAULT);
                return;
            case WarehousePackage.PROCESS_TYPE__EXITS:
                getExits().clear();
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case WarehousePackage.PROCESS_TYPE__NODE:
                return node != null && !node.isEmpty();
            case WarehousePackage.PROCESS_TYPE__NOTE:
                return note != null && !note.isEmpty();
            case WarehousePackage.PROCESS_TYPE__BLOCK:
                return block != null && !block.isEmpty();
            case WarehousePackage.PROCESS_TYPE__CONNECTION:
                return connection != null && !connection.isEmpty();
            case WarehousePackage.PROCESS_TYPE__ISBLOCK:
                return isblock != ISBLOCK_EDEFAULT;
            case WarehousePackage.PROCESS_TYPE__EXITS:
                return exits != null && !exits.isEmpty();
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (isblock: ");
        result.append(isblock);
        result.append(')');
        return result.toString();
    }

} //ProcessTypeImpl
